package net.sx.minemodule.mvp.presenters;

import com.kedll.library.mvp.BasePresenter;
import com.kedll.library.util.ToastUtil;

import net.sx.minemodule.MineApiUtils;
import net.sx.minemodule.mvp.views.MineOrderDetailView;

public class MineOrderDetailPresenter extends BasePresenter<MineOrderDetailView> {

    public MineOrderDetailPresenter(MineOrderDetailView mView) {
        super(mView);
    }

    public void getOrderDetailInfo(String orderId){
        MineApiUtils.getOrderDetail(orderId, orderListDetailBean ->{
            mView.getOrderInfo(orderListDetailBean);
        }, throwable ->{

        });
    }

    public void cancelOrder(String orderId, String type){
        MineApiUtils.cancelOrder(orderId,type , msg -> {
            mView.cancelOrder(msg);
        }, th -> {
            ToastUtil.showToast(th.getMessage());
        });
    }

    public void obtainGoods(int orderId){
        MineApiUtils.obtainGoods(orderId, 0, res -> {
            if (res > 0) {
                ToastUtil.showToast("成功");
                mView.receiptedOrder("成功");
            }
        }, th -> {
            ToastUtil.showToast(th.getMessage());
        });
    }
}
